package jp.co.hcs.attendancemanagement.data.dao.impl;

import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.List;

import jp.co.hcs.attendancemanagement.data.dao.EmployeeMasterDAO;
import jp.co.hcs.attendancemanagement.data.entity.EmployeeMaster;
import jp.co.hcs.attendancemanagement.data.entity.ex.EmployeeMasterExample;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.AttendanceSettingInitDTO;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.DailyWorkingActualResultDTO;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.EmployeeCompanyDTO;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.StampActualResultDTO;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.TimeSettingInitDTO;
import jp.co.hcs.attendancemanagement.inputtableb.logic.dto.EmployerInfoDTO;

public class EmployeeMasterDAOImpl extends BaseDAOImpl implements EmployeeMasterDAO {

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
	
    public EmployeeMasterDAOImpl() {
        super();
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int countEmployeeMasterByExample(EmployeeMasterExample example) throws SQLException {
        Integer count = (Integer)  sqlMapClient.queryForObject("tb5_shain_master.ibatorgenerated_countByExample", example);
        return count;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int deleteEmployeeMasterByExample(EmployeeMasterExample example) throws SQLException {
        int rows = sqlMapClient.delete("tb5_shain_master.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int deleteEmployeeMasterByPrimaryKey(String employeeId) throws SQLException {
        EmployeeMaster key = new EmployeeMaster();
        key.setEmployeeId(employeeId);
        int rows = sqlMapClient.delete("tb5_shain_master.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public void insertEmployeeMaster(EmployeeMaster record) throws SQLException {
        sqlMapClient.insert("tb5_shain_master.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public void insertEmployeeMasterSelective(EmployeeMaster record) throws SQLException {
        sqlMapClient.insert("tb5_shain_master.ibatorgenerated_insertSelective", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    @SuppressWarnings("unchecked")
    public List<EmployeeMaster> selectEmployeeMasterByExample(EmployeeMasterExample example) throws SQLException {
        List<EmployeeMaster> list = sqlMapClient.queryForList("tb5_shain_master.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public EmployeeMaster selectEmployeeMasterByPrimaryKey(String employeeId) throws SQLException {
        EmployeeMaster key = new EmployeeMaster();
        key.setEmployeeId(employeeId);
        EmployeeMaster record = (EmployeeMaster) sqlMapClient.queryForObject("tb5_shain_master.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int updateEmployeeMasterByExampleSelective(EmployeeMaster record, EmployeeMasterExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("tb5_shain_master.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int updateEmployeeMasterByExample(EmployeeMaster record, EmployeeMasterExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("tb5_shain_master.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int updateEmployeeMasterByPrimaryKeySelective(EmployeeMaster record) throws SQLException {
        int rows = sqlMapClient.update("tb5_shain_master.ibatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    public int updateEmployeeMasterByPrimaryKey(EmployeeMaster record) throws SQLException {
        int rows = sqlMapClient.update("tb5_shain_master.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }
    
    public EmployerInfoDTO getEmployerInfo(String employerCode) throws SQLException{
    	EmployerInfoDTO employerInfoDTO = (EmployerInfoDTO)sqlMapClient.queryForObject("tb5_shain_master.getEmployerInfo",employerCode);
//    	EmployerInfoDTO employerInfoDTO = new EmployerInfoDTO(); 
//    	employerInfoDTO.setEmployerCode("123");
//    	employerInfoDTO.setName("HongHai");
//    	employerInfoDTO.setFamilyName("Truong");
//    	employerInfoDTO.setEmployerName();
//    	employerInfoDTO.setDivisionName("Tinh Van");
//    	employerInfoDTO.setDepartmentName("TVO");
    	if(employerInfoDTO != null)
    	{
    		employerInfoDTO.setEmployerName();
    	}
    	return employerInfoDTO;
    }
    
    public EmployeeCompanyDTO getEmployeeCompanyInfoDTO(String employeeId) throws SQLException{
    	return (EmployeeCompanyDTO) sqlMapClient.queryForObject("tb5_shain_master.getEmployeeCompanyInfo", employeeId);
    }
    
    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table tb5_shain_master
     *
     * @ibatorgenerated Wed Mar 07 22:22:22 GMT+07:00 2012
     */
    private static class UpdateByExampleParms extends EmployeeMasterExample {
        private Object record;

        public UpdateByExampleParms(Object record, EmployeeMasterExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}